﻿@inject AdminAreaSettings adminAreaSettings
@{
    //page title
    ViewBag.Title = Loc["Admin.Reports.LowStockReport"];
}

<div class="row">
    <div class="col-md-12">
        <div class="x_panel light form-fit">
            <div class="x_title">
                <div class="caption level-caption">
                    <i class="fa fa-cubes"></i>
                    @Loc["Admin.Reports.LowStockReport"]
                </div>
            </div>
            <div class="x_content form">
                <div class="form-horizontal">
                    <div class="x_content">
                        <div id="products-grid"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(document).ready(function() {
        $("#products-grid").kendoGrid({
            dataSource: {
                transport: {
                    read: {
                        url: "@Html.Raw(Url.Action("LowStockReportList", "Reports", new { area = Constants.AreaAdmin }))",
                        type: "POST",
                        dataType: "json",
                        data: addAntiForgeryToken
                    }
                },
                schema: {
                    data: "Data",
                    total: "Total",
                    errors: "Errors"
                },
                error: function(e) {
                    display_kendoui_grid_error(e);
                    // Cancel the changes
                    this.cancelChanges();
                },
                pageSize: @(adminAreaSettings.DefaultGridPageSize),
                serverPaging: true,
                serverFiltering: true,
                serverSorting: true
            },
            pageable: {
                refresh: true,
                pageSizes: [@(adminAreaSettings.GridPageSizes)]
            },
            editable: {
                confirmation: false,
                mode: "inline"
            },
            scrollable: false,
            columns: [
                {
                    field: "Name",
                    title: "@Loc["Admin.Catalog.Products.Fields.Name"]",
                    width: 300,
                    //if not a grouped product, then display                   
                    template: '<a class="k-link" href="@Url.Action("Edit", "Product", new { area = Constants.AreaAdmin })/#=Id#">#:Name# # if(Attributes !== null) {# <br /><i> #=Attributes# </i> #} #</a>',
                }, {
                    field: "ManageInventoryMethod",
                    title: "@Loc["Admin.Catalog.Products.Fields.ManageInventoryMethod"]",
                    width: 150
                }, {
                    field: "StockQuantity",
                    title: "@Loc["Admin.Catalog.Products.Fields.StockQuantity"]",
                    width: 100
                }, {
                    field: "Published",
                    title: "@Loc["Admin.Catalog.Products.Fields.Published"]",
                    width: 100,
                    headerAttributes: { style: "text-align:center" },
                    attributes: { style: "text-align:center" },
                    template: '# if(Published) {# <i class="fa fa-check" aria-hidden="true" style="color:green"></i> #} else {# <i class="fa fa-times" aria-hidden="true" style="color:red"></i> #} #'
                }
            ]
        });
    });
</script>